<?php
//Setting

if ( ! isset( $content_width ) ) $content_width = 900;
// Disable WordPress version reporting as a basic protection against attacks
function remove_generators() {
return '';
}		
add_filter('the_generator','remove_generators');
// Add thumbnail support
add_theme_support( 'post-thumbnails' );
// Disable the admin bar, set to true if you want it to be visible.
show_admin_bar(FALSE);
// Shortcodes
include('shortcodes.php');
// Add theme support for Automatic Feed Links
add_theme_support( 'automatic-feed-links' );
// Custom Navigation
add_theme_support('nav-menus');
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
	array(
	  // - Header Navigation
	  'header-menu' => 'Header Navigation',
	)
);
}
// Sidebars
if (function_exists('register_sidebar')) {
// Right Sidebar
register_sidebar(array(
	'name'=> 'Right Sidebar',
	'id' => 'right_sidebar',
	'before_widget' => '<li id="%1$s" class="widget %2$s">',
	'after_widget' => '</li>',
	'before_title' => '<h4>',
	'after_title' => '</h4>',
));
// Footer Sidebar
register_sidebar(array(
	'name'=> 'Footer Sidebar',
	'id' => 'footer_sidebar',
	'before_widget' => '<div id="%1$s" class="four columns %2$s">',
	'after_widget' => '</div>',
	'before_title' => '<h4>',
	'after_title' => '</h4>',
));
}
// Comments
// Custom callback to list comments in the Foundation style
function custom_comments($comment, $args, $depth) {
 $GLOBALS['comment'] = $comment;
   $GLOBALS['comment_depth'] = $depth;
 ?>
<li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
<div class="comment-author vcard"><?php commenter_link() ?></div>
<div class="comment-meta"><?php printf(__('Posted %1$s at %2$s <span class="meta-sep">|</span> <a href="%3$s" title="Permalink to this comment">Permalink</a>', 'Foundation'),
  get_comment_date(),
  get_comment_time(),
  '#comment-' . get_comment_ID() );
  edit_comment_link(__('Edit', 'Foundation'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
<?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'Foundation') ?>
<div class="comment-content">
  <?php comment_text() ?>
</div>
<?php // echo the comment reply link
  if($args['type'] == 'all' || get_comment_type() == 'comment') :
	  comment_reply_link(array_merge($args, array(
		  'reply_text' => __('Reply','Foundation'),
		  'login_text' => __('Log in to reply.','Foundation'),
		  'depth' => $depth,
		  'before' => '<div class="comment-reply-link">',
		  'after' => '</div>'
	  )));
  endif;
  ?>
<?php } // end custom_comments
  // Custom callback to list pings
  function custom_pings($comment, $args, $depth) {
		 $GLOBALS['comment'] = $comment;
		  ?>
			<li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
			<div class="comment-author"><?php printf(__('By %1$s on %2$s at %3$s', 'Foundation'),
			  get_comment_author_link(),
			  get_comment_date(),
			  get_comment_time() );
			  edit_comment_link(__('Edit', 'Foundation'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
			<?php if ($comment->comment_approved == '0') _e('\t\t\t\t\t<span class="unapproved">Your trackback is awaiting moderation.</span>\n', 'Foundation') ?>
			<div class="comment-content">
			  <?php comment_text() ?>
</div>
<?php } // end custom_pings
  // Produces an avatar image with the hCard-compliant photo class
  function commenter_link() {
	  $commenter = get_comment_author_link();
	  if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
		  $commenter = ereg_replace( '(<a[^>]* class=[\'"]?)', '\\1url ' , $commenter );
	  } else {
		  $commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );
	  }
	  $avatar_email = get_comment_author_email();
	  $avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, 35 ) );
	  echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
  } // end commenter_link
  // Custom Pagination
  /**
   * Retrieve or display pagination code.
   *
   * The defaults for overwriting are:
   * 'page' - Default is null (int). The current page. This function will
   *      automatically determine the value.
   * 'pages' - Default is null (int). The total number of pages. This function will
   *      automatically determine the value.
   * 'range' - Default is 3 (int). The number of page links to show before and after
   *      the current page.
   * 'gap' - Default is 3 (int). The minimum number of pages before a gap is 
   *      replaced with ellipses (...).
   * 'anchor' - Default is 1 (int). The number of links to always show at begining
   *      and end of pagination
   * 'before' - Default is '<div class="emm-paginate">' (string). The html or text 
   *      to add before the pagination links.
   * 'after' - Default is '</div>' (string). The html or text to add after the
   *      pagination links.
   * 'next_page' - Default is '__('&raquo;')' (string). The text to use for the 
   *      next page link.
   * 'previous_page' - Default is '__('&laquo')' (string). The text to use for the 
   *      previous page link.
   * 'echo' - Default is 1 (int). To return the code instead of echo'ing, set this
   *      to 0 (zero).
   *
   * @author Eric Martin <eric@ericmmartin.com>
   * @copyright Copyright (c) 2009, Eric Martin
   * @version 1.0
   *
   * @param array|string $args Optional. Override default arguments.
   * @return string HTML content, if not displaying.
   */
  function emm_paginate($args = null) {
	$defaults = array(
		'page' => null, 'pages' => null, 
		'range' => 3, 'gap' => 3, 'anchor' => 1,
		'before' => '<ul class="pagination">', 'after' => '</ul>',
		'title' => __('<li class="unavailable"></li>'),
		'nextpage' => __('&raquo;'), 'previouspage' => __('&laquo'),
		'echo' => 1
	);
	$r = wp_parse_args($args, $defaults);
	extract($r, EXTR_SKIP);
	if (!$page && !$pages) {
		global $wp_query;
		$page = get_query_var('paged');
		$page = !empty($page) ? intval($page) : 1;
		$posts_per_page = intval(get_query_var('posts_per_page'));
		$pages = intval(ceil($wp_query->found_posts / $posts_per_page));
	}
	$output = "";
	if ($pages > 1) {	
		$output .= "$before<li>$title</li>";
		$ellipsis = "<li class='unavailable'>...</li>";
		if ($page > 1 && !empty($previouspage)) {
			$output .= "<li><a href='" . get_pagenum_link($page - 1) . "'>$previouspage</a></li>";
		}
		$min_links = $range * 2 + 1;
		$block_min = min($page - $range, $pages - $min_links);
		$block_high = max($page + $range, $min_links);
		$left_gap = (($block_min - $anchor - $gap) > 0) ? true : false;
		$right_gap = (($block_high + $anchor + $gap) < $pages) ? true : false;
		if ($left_gap && !$right_gap) {
			$output .= sprintf('%s%s%s', 
				emm_paginate_loop(1, $anchor), 
				$ellipsis, 
				emm_paginate_loop($block_min, $pages, $page)
			);
		}
		else if ($left_gap && $right_gap) {
			$output .= sprintf('%s%s%s%s%s', 
				emm_paginate_loop(1, $anchor), 
				$ellipsis, 
				emm_paginate_loop($block_min, $block_high, $page), 
				$ellipsis, 
				emm_paginate_loop(($pages - $anchor + 1), $pages)
			);
		}
		else if ($right_gap && !$left_gap) {
			$output .= sprintf('%s%s%s', 
				emm_paginate_loop(1, $block_high, $page),
				$ellipsis,
				emm_paginate_loop(($pages - $anchor + 1), $pages)
			);
		}
		else {
			$output .= emm_paginate_loop(1, $pages, $page);
		}
		if ($page < $pages && !empty($nextpage)) {
			$output .= "<li><a href='" . get_pagenum_link($page + 1) . "'>$nextpage</a></li>";
		}
		$output .= $after;
	}
	if ($echo) {
		echo $output;
	}
	return $output;
  }
  /**
   * Helper function for pagination which builds the page links.
   *
   * @access private
   *
   * @author Eric Martin <eric@ericmmartin.com>
   * @copyright Copyright (c) 2009, Eric Martin
   * @version 1.0
   *
   * @param int $start The first link page.
   * @param int $max The last link page.
   * @return int $page Optional, default is 0. The current page.
   */
  function emm_paginate_loop($start, $max, $page = 0) {
	$output = "";
	for ($i = $start; $i <= $max; $i++) {
		$output .= ($page === intval($i)) 
			? "<li class='current'><a href='#'>$i</a></li>" 
			: "<li><a href='" . get_pagenum_link($i) . "'>$i</a></li>";
	}
	return $output;
  } 
require('ts-framework/framework.php'); 

  
  ?>